package com.haoshuang.zhouzhoubang.ui.adapter

import com.haoshuang.zhouzhoubang.databinding.ItemUploadExampleBinding
import com.haoshuang.zhouzhoubang.ui.dialog.UploadExample
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.util.SmartGlideImageLoader
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import com.mufeng.libs.utils.view.clickWithTrigger
import com.mufeng.libs.utils.view.load

/**
 * 上传示例适配器
 */
class UploadExampleAdapter(data: MutableList<UploadExample>) : BaseBindingQuickAdapter<UploadExample, ItemUploadExampleBinding>(data) {

    override fun onBindViewHolder(holder: BaseBindingHolder, position: Int, item: UploadExample?) {
        if (item == null) return
        holder.getViewBinding<ItemUploadExampleBinding>().apply {

            tvTitle.text = item.title
            rivImage.load(item.url)

            rivImage.clickWithTrigger {
                XPopup.Builder(context)
                    .asImageViewer(rivImage, item.url, SmartGlideImageLoader())
                    .show()
            }
        }

    }
}
